package com.baitai.system.service.impl;

import java.util.List;

import com.baitai.common.core.domain.model.LoginUser;
import com.baitai.common.utils.DateUtils;
import com.baitai.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baitai.system.mapper.UserOpinionMapper;
import com.baitai.system.domain.UserOpinion;
import com.baitai.system.service.IUserOpinionService;

/**
 * 用户意见
 * Service业务层处理
 *
 * @author xx
 * @date 2024-11-22
 */
@Service
public class UserOpinionServiceImpl implements IUserOpinionService {
    @Autowired
    private UserOpinionMapper userOpinionMapper;

    /**
     * 查询用户意见
     *
     * @param opinionId 用户意见
     *                  主键
     * @return 用户意见
     */
    @Override
    public UserOpinion selectUserOpinionByOpinionId(Long opinionId) {
        return userOpinionMapper.selectUserOpinionByOpinionId(opinionId);
    }

    /**
     * 查询用户意见
     *
     * @param userId 用户意见
     *                  主键
     * @return 用户意见
     */
    @Override
    public List<UserOpinion> selectUserOpinionByUserId(Long userId) {
        return userOpinionMapper.selectUserOpinionByUserId(userId);
    }

    /**
     * 查询用户意见
     * 列表
     *
     * @param userOpinion 用户意见
     * @return 用户意见
     */
    @Override
    public List<UserOpinion> selectUserOpinionList(UserOpinion userOpinion) {
        return userOpinionMapper.selectUserOpinionList(userOpinion);
    }

    /**
     * 新增用户意见
     *
     * @param userOpinion 用户意见
     * @return 结果
     */
    @Override
    public int insertUserOpinion(UserOpinion userOpinion) {
        userOpinion.setCreateTime(DateUtils.getNowDate());
        LoginUser user = SecurityUtils.getLoginUser();
        userOpinion.setUseriId(user.getUserId());
        userOpinion.setUserName(user.getUsername());
        return userOpinionMapper.insertUserOpinion(userOpinion);
    }

    /**
     * 修改用户意见
     *
     * @param userOpinion 用户意见
     * @return 结果
     */
    @Override
    public int updateUserOpinion(UserOpinion userOpinion) {
        return userOpinionMapper.updateUserOpinion(userOpinion);
    }

    /**
     * 批量删除用户意见
     *
     * @param opinionIds 需要删除的用户意见
     *                   主键
     * @return 结果
     */
    @Override
    public int deleteUserOpinionByOpinionIds(Long[] opinionIds) {
        return userOpinionMapper.deleteUserOpinionByOpinionIds(opinionIds);
    }

    /**
     * 删除用户意见
     * 信息
     *
     * @param opinionId 用户意见
     *                  主键
     * @return 结果
     */
    @Override
    public int deleteUserOpinionByOpinionId(Long opinionId) {
        return userOpinionMapper.deleteUserOpinionByOpinionId(opinionId);
    }
}
